<template>
  <div id="app">
    <h1>todoList</h1>
    <AddNew @submitNewItem="addNewItem"></AddNew>
    <TheList :list="todoList" @handleJudge="toDone"></TheList>
    <hr />
    <TheList :list="doneList" :listType="true" @handleDelete="toDelete"></TheList>
  </div>
</template>

<script>
import AddNew from "@/components/levele4Project/Dome5/Dome5-2/AddNew.vue";
import TheList from "@/components/levele4Project/Dome5/Dome5-2/TheList.vue";
export default {
  name: "TodoList",
  data(){
    return{
      todoList: [],
      doneList: [],
    };
  },
  methods: {
    addNewItem(newItem) {
      this.todoList.push(newItem)
    },
    toDone(index) {
      this.doneList.push(this.todoList.splice(index,1)[0]);
    },
    toDelete(index) {
      this.doneList.splice(index,1);
    }
  },
  components:{
    AddNew,
    TheList,
  }
}
</script>

<style scoped>
*{
  box-sizing: border-box;
}
#app{
  width: 500px;
  margin: 0 auto;
}
h1{
  font-size: 24px;
  color: white;
  text-align: center;
}
#add{
  width: 100%;
  background-color: #7c7b79;
}
.wait{
  width: 100%;
  background-color: #16cba6;
  height: 300px;
  box-sizing: border-box;
  opacity: 0.76;
  //display: flex;
  //flex-wrap: wrap;
  overflow: auto;
}
.finished{
  width: 100%;
  background-color: #7d8f8a;
  height: 200px;
  opacity: 0.67;
  //display: flex;
  ////flex-wrap: wrap;
  overflow: auto;
}
</style>